# _*_coding: UTF-8 _*_
# author:jamesfeng2009
# time:2024/2/14 21:30
# 文心一言demo  https://aistudio.baidu.com/modelsdetail/754?modelId=754
import erniebot

erniebot.api_type = 'aistudio'
erniebot.access_token = 'b45ed3a5bb95610b66463d4bfe0ce2a4d2fa3bab'
model = 'ernie-3.5'
messages = [{'role': 'user', 'content': "请问你能以《你好，世界》为题，写一首现代诗吗？"}]
first_response = erniebot.ChatCompletion.create(
    model=model,
    messages=messages
)

messages.append(first_response.to_message())
messages.append({'role': 'user', 'content': "谢谢你！请问你能把这首诗改写成七言绝句吗？"})
second_response = erniebot.ChatCompletion.create(
    model=model,
    messages=messages
)
print(second_response.get_result())
